#include <bits/stdc++.h>
using namespace std;
int n, cnt;
int a[100010], b[100010] , c[100010], d[3][100010];
int maxa(){
    int maxn = a[1];
    for(int i = 2; i <= n; i++){
        if(a[i] > maxn) maxn = a[i];
    }
    return maxn;
}
int fd(int m){
    int cnt = 1;
    for(int i = 1; i <= n; i++){
        if(a[i] > m){
            d[1][cnt] = i;
            d[2][cnt] = a[i];
            cnt++;
        }
    }
    cnt--;
    int mina = d[2][1], minb = 1;
    for(int i = 2; i <= cnt; i++){
        if(d[2][i] < mina){
            mina = d[2][i];
            minb = i;
        }
    }
    return d[1][minb];
}
int main(){
    freopen("duel.in", "r", stdin);
    freopen("duel.out", "w", stdout);
    cin >> n;
    for(int i = 1; i <= n; i++){ cin >> a[i]; b[i] = a[i];}
    for(int i = 1; i <= n; i++){
        if(b[n] >= maxa()){
            cout << n - cnt;
            break;
        }
            c[i] = fd(b[i]);
            a[c[i]] = 0;
            b[i] = 0;
            cnt++;
    }
    return 0;
}
